package puzzle.ftest.solver.builtin;

import java.io.IOException;
import java.io.Reader;

import org.junit.Test;

import puzzle.common.data.AbstractBoard;
import puzzle.common.loader.AbstractLoader;
import puzzle.common.loader.AbstractProblemDictionary;
import puzzle.common.solver.SolverAbortingException;
import puzzle.common.view.swing.PuzzleSolverAppMetadata;
import puzzle.ftest.solver.base.SolverTestBase;

public abstract class SolverTestWithBuiltinProblemsBase<B extends AbstractBoard<B>> extends
		SolverTestBase<B> {

	public SolverTestWithBuiltinProblemsBase(PuzzleSolverAppMetadata<B> metadata) {
		super(metadata);
	}

	@Test
	public void testSolverWithBuiltinProblems() throws SolverAbortingException, IOException {
		AbstractProblemDictionary d = m_metadata.createBuiltinProblemDictionary();
		AbstractLoader<B> l = m_metadata.createLoader();

		for (String name : d.getProblemNames()) {
			Reader r = d.getProblemData(name);
			B b = l.load(r);
			solve(name, b);
		}
	}

}
